package com.text.day3_2;

import java.util.LinkedList;

public class StackDemo {
    public static void main(String[] args) {
        String s = "1+((a+b)/c)+5/(2+a)";

        boolean flag = testXkh(s);
        System.out.println(flag);
    }

    private static boolean testXkh(String s) {
        char[] ch = s.toCharArray();
        LinkedList<Integer> objects = new LinkedList<>();
        for (char c : ch) {
            if (c == '(') {
                objects.push(1);
            }
            if (c == ')') {
                if (objects.size() == 0)
                    return false;
                objects.pop();
            }

        }
        return objects.size() == 0;
    }

}
